﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConditionBuilder.cs" company="Microsoft">
//   Microsoft
// </copyright>
// <summary>
//   Defines the ConditionBuilder type.
// </summary>
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// --------------------------------------------------------------------------------------------------------------------

namespace MySemanticSearch.Web.QueryBuilder
{
    using System.Collections.Generic;

    using MySemanticSearch.Web.QueryBuilder.Conditions;

    /// <summary>
    /// This class is in charge of create ICondition Objects
    /// </summary>
    public class ConditionBuilder
    {
        /// <summary>
        /// Creates an and condition between two given conditions
        /// </summary>
        /// <param name="left">
        /// The left condition
        /// </param>
        /// <param name="right">
        /// The right condition
        /// </param>
        /// <returns>
        /// An And Condition
        /// </returns>
        public ICondition HandleAndCondition(ICondition left, ICondition right)
        {
            return new AndCompoundCondition(left, right);
        }

        /// <summary>
        /// Creates a full text condition
        /// </summary>
        /// <param name="text">
        /// The text to search for
        /// </param>
        /// <returns>
        /// a new full text condition
        /// </returns>
        public ICondition HandleFullTextCondition(string text)
        {
            return new FullTextCondition(text);
        }

        /// <summary>
        /// Creates a new Tag condition
        /// </summary>
        /// <param name="fileTable">
        /// The file table.
        /// </param>
        /// <param name="tags">
        /// The tags to search for
        /// </param>
        /// <returns>
        /// a new tag condition
        /// </returns>
        public ICondition HandleTagCondition(string fileTable, LinkedList<string> tags)
        {
            return new ByTagCondition(fileTable, tags);
        }

        /// <summary>
        /// creates a new Document property condition
        /// </summary>
        /// <param name="propertyName">
        /// The property name.
        /// </param>
        /// <param name="propertyValue">
        /// The property value.
        /// </param>
        /// <returns>
        /// a new DocumentPropertyCondition
        /// </returns>
        public ICondition HandleDocumentPropertyCondition(string propertyName, string propertyValue)
        {
            return new DocumentPropertyCondition(propertyName, propertyValue);
        }
    }
}